fix(perps): use live price for reverse position orders#28897
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b78150d. Configure here.
| PERPS_EVENT_PROPERTY, | ||
| PERPS_EVENT_VALUE, | ||
| } from '../constants/eventNames'; | ||
| import { ESTIMATED_FEE_RATE } from '../constants/hyperLiquidConfig'; |
There was a problem hiding this comment.
Unused export ESTIMATED_FEE_RATE after removing its only consumer
Low Severity
The ESTIMATED_FEE_RATE import was removed from TradingService.ts, but the constant is still exported from hyperLiquidConfig.ts. A codebase-wide grep confirms zero remaining consumers — it is now dead code. Its comment explicitly ties it to "flip operations," which no longer use it.
Reviewed by Cursor Bugbot for commit b78150d. Configure here.
|
✅ E2E Fixture Validation — Schema is up to date |
|





Description
Fixes reverse-position failures in perps by stopping
flipPosition()from sending the position entry price as the ordercurrentPrice.The reverse-position flow was using stale entry pricing during order placement, which could cause the provider to validate and submit the flip order against the wrong price. This change makes the flip flow rely on live provider pricing instead, and updates the related regression coverage and analytics expectation.
Changelog
CHANGELOG entry: Fixed a bug that was causing reverse position orders in Perps to fail when stale entry pricing was used during order placement
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2946
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Touches order submission behavior for position flips, which can impact execution/validation if any provider implicitly relied on
currentPrice; otherwise the change is small and covered by updated unit tests.Overview
Fixes Perps reverse/flip orders by removing the
currentPrice(positionentryPrice) field fromTradingService.flipPosition()order submissions so the provider validates/prices using live market data.Updates flip analytics to compute
order_valuefrom the executed average price (falling back to entry price if missing), and adjustsTradingService.test.tsby deleting the old balance/fee-guard tests and assertingcurrentPriceis never passed.Reviewed by Cursor Bugbot for commit b78150d. Bugbot is set up for automated code reviews on this repo. Configure here.